# -*- mode: snippet -*-
# name: bar plot with error bar and label - matplotlib
# key: matplotlib.bar.error.label
# contributor: Shuguang Sun
# --
# -*- coding: utf-8 -*-
fig, ax = plt.subplots()
$0
p1 = ax.bar(ind, menMeans, width, yerr=menStd, label='Men')
# stack
p2 = ax.bar(ind, womenMeans, width,
            bottom=menMeans, yerr=womenStd, label='Women')

ax.axhline(0, color='grey', linewidth=0.8)
ax.set_ylabel('Scores')
ax.set_title('Scores by group and gender')
ax.set_xticks(ind)
ax.set_xticklabels(('G1', 'G2', 'G3', 'G4', 'G5'))
ax.legend()

# Label with label_type 'center' instead of the default 'edge'
ax.bar_label(p1, label_type='center')
ax.bar_label(p2, label_type='center')
ax.bar_label(p2)

plt.show()